import 'package:flutter/material.dart';

class Loading  {


  static Loading _instance = Loading._internal();

  factory Loading(){
    return _instance;
  }
  Loading._internal();

  static OverlayEntry entry;

  static show(BuildContext context) {
    entry = OverlayEntry(builder: (BuildContext con){      
      return Center(
        child:Container(
          decoration: BoxDecoration(
            color: Color.fromRGBO(0, 0, 0, 0.6),
            borderRadius: BorderRadius.circular(8.0),
          ),
          child: Column(
          mainAxisSize:MainAxisSize.min,
          mainAxisAlignment:MainAxisAlignment.center,
          children:<Widget>[
            Padding(
              padding: EdgeInsets.only(top:16.0),
              child: SizedBox(
                width:60,
                height:60,
                child:CircularProgressIndicator(strokeWidth: 6.0,),
              ),  
            ),
            Padding(
              padding: EdgeInsets.all(16.0),
              child: Text(
                '加载中...',
                style: TextStyle(
                  decoration: TextDecoration.none,
                  color: Colors.white,
                  fontSize: 18.0
                ),
              ),
            )
          ],
        ),)
      );
    });

    Overlay.of(context).insert(entry);
  }

  static dismissLoading() {
    // Future.delayed(Duration(milliseconds: 500),(){
      
    // });
    entry?.remove();
  }


}

